var app = getApp();
var constract = require('../../../utils/constract.js');
Page({
  data: {

  },
  onLoad: function (options) {
    var that = this;
    app.Verification(function (token) {
      wx.request({
        url: constract.index, //查看首页的名片信息
        header: { token: token },
        success: function (res) {
          var userInfo = res.data.data;
          if (userInfo.state == 0) {
            that.setData({
              createOrView: 0,
              addInfo: userInfo
            })
          } else {
            that.setData({
              createOrView: 1
            })
          }
        }
      });
    })
    that.setData({
      avatar: options.avatar,
      name: options.name,
      dimension: options.qr_code
    })
  },
  goAdd: function(){
    var that = this;
    wx.redirectTo({
      url: '/pages/add-card/add-card?avatar=' + that.data.addInfo.avatar + '&name=' + that.data.addInfo.name
    })
  },
  goIndex: function(){
    wx.switchTab({
      url:'/pages/index/index'
    })
  }
  

  
})